package xyz.xtgl.config.helper;

import common.core.util.CommonUtil;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyDispatcherServlet extends DispatcherServlet {
	
	private static final long serialVersionUID = -4519806488407140715L;
	
	@Override
	protected void render(ModelAndView mv, HttpServletRequest request, HttpServletResponse response) throws Exception {
		String[] paths=request.getRequestURI().split("[\\/]+");
		if(paths.length == 4 && CommonUtil.isNotEmpty(mv.getViewName())){
			mv.setViewName(paths[1]+"/"+ CommonUtil.dbForDBToFistLowercaseHump(paths[2])+"/"+mv.getViewName());
		}
//		Integer dictionaryVersion= redisCache.get("constant:dictionary:js:version",Integer.class);
//		dictionaryVersion = CommonUtil.isEmptyReturn(dictionaryVersion,0);
//		request.setAttribute("dictionaryVsersion", "dictionaryVsersion");
		super.render(mv, request, response);
	}
}

